package com.example.demo;

import java.util.Objects;

/**
 * description: User <br>
 * date: 2020/8/12 09:18 <br>
 *
 * @author: ZhangYixin <br>
 * version: 1.0 <br>
 */
public class User {



    private String name ;

    private String sex;

    private int age;

    public User(String name, String sex, int age) {
        this.name = name;
        this.sex = sex;
        this.age = age;
    }

    public User(String name) {
        this.name = name;
        System.out.println("法外狂徒");
        System.out.println(name);
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getSex() {
        return sex;
    }

    public void setSex(String sex) {
        this.sex = sex;
    }

    public int getAge() {
        return age;
    }

    public void setAge(int age) {
        this.age = age;
    }

    public void setAll(String name ,String sex, int age){
        this.name = name;
        this.sex = sex;
        this.age = age;
        System.out.println("name:"+name+"sex:"+sex+"age:"+age);
    }

    @Override
    public int hashCode() {
        System.out.println("hashcode:-------name:"+name+"sex:"+sex+"age:"+age);
        return Objects.hash(this.name,this.age,this.sex);
    }

    @Override
    public boolean equals(Object obj) {
        if (this == obj) {
            return true;
        }
        if (obj == null || this.getClass() != obj.getClass()){
            return false;
        }
        User user = (User) obj;
        return Objects.equals(this.name,user.name) && this.age == user.age && Objects.equals(this.sex,user.sex);
    }
}
